package com.deep.stream.server.controller;

import com.deep.stream.server.dao.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.function.Supplier;

/**
 * @author deeprado
 * @date 2021/9/7 15:26
 */
@RestController
public class FunctionOutputController {

    @Autowired
    private StreamBridge streamBridge;

    @Bean
    public Supplier<String> autoSend() {
        return () -> "哈喽";
    }

    @RequestMapping("/userSend")
    public void sendUserInfo(UserInfo userInfo) {
        streamBridge.send("user-out-0", userInfo);
    }

    @RequestMapping("/kafkaSend")
    public void sendKafkaInfo(UserInfo userInfo) {
        streamBridge.send("kafka-out-0", userInfo);
    }

    @RequestMapping("/kafkaSend2")
    public void sendKafkaInfo2(UserInfo userInfo) {
        streamBridge.send("kafka2-out-0", userInfo);
    }
}
